#undef NDEBUG
#include <cassert>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "person.hpp"
#include "student.hpp"

using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::ends;
using std::flush;
using std::clog;
using std::vector;
using std::string;
using std::istream;
using std::ostream;
using std::ifstream;
using std::ofstream;
using std::istringstream;
using std::ostringstream;
using std::fstream;
using std::stringstream;

int main(int argc, char *argv[]) {
    assert(argc > 1);
    string fname(argv[1]);

    vector<string> line_vec;
    vector<string> word_vec;

    ifstream infile(fname);
    string line;
    while (getline(infile, line)) {
        line_vec.push_back(line);
    }
    for (auto &e : line_vec) {
        cout << e << endl;
    }
    infile.close();

    infile.open(fname, fstream::in);
    string word;
    while (infile >> word) {
        word_vec.push_back(word);
    }
    string::size_type word_len;
    for (auto &e : word_vec) {
        word_len = e.size();
        if (word_len > 5) {
            cout << e << endl;
        }
    }
    infile.close();


    infile.open(fname);

    Student s;
    while(read_student(infile, s)) {
        print_student(cout, s);
        cout << endl;
        print_person(cout, s);
        cout << endl;
    }

    return 0;
}
